{% extends "admin/base.html" %}

{% block extrastyle %}
<style type="text/css">
	@import "/media/js/simp/dojo/resources/dojo.css";
	@import "/media/js/simp/dijit/themes/tundra/tundra.css";
	/*@import "/media/js/simp/dojox/grid/_grid/tundraGrid.css";*/
	@import "/media/js/simp/simp/simpTundra.css";
</style>
{% endblock extrastyle %}

{% block extrahead %}
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
<meta http-equiv="PRAGMA" content="NO-CACHE" /> 
{% googleanalytics %}
<script type="text/javascript">
var djConfig = {
	parseOnLoad: true,
	isDebug: true, 
	debugAtAllCosts: false,
	usePlainJson: true,
};
</script>
<script type="text/javascript" src="/media/js/simp/dojo/dojo.js"></script>

<script type="text/javascript">
	dojo.require("dojo.parser");
	dojo.require("dijit.form.Button");
	
	function initsimp(ImageId) {
		console.debug("button on click")
		var request = {
			url: "/simpdemo/initsimp/",
			content: {
				id: ImageId,
				preset: -1,
				module: null,
			},
			load: function(data){
				if (data.location != null) {
							window.location = data.location;
				}
			},
			error: function(data){
				console.debug("An error occurred: " + data);
				},
			timeout: 2000,
		};
		dojo.xhrPost(request);	
	}
</script>
{% endblock extrahead %}

{% block bodyclass %}tundra{% endblock %}

{% block content %}
<div id="simpDemoImageSelectArea">
	<h1>image modified in django-simp</h1>
	<p>
		<img src="{{galleryImage.get_image_url}}" alt="modified image" />
		<p>please enter a describtion of your image to add it to the gallery<br />
		<textarea id="imageDesc" rows="10" cols="100">{{galleryImage.desc}}</textarea>
		</p>
		<div dojoType="dijit.form.Button">
			<b>save</b>
			<script type="dojo/method" event="onClick">
				console.debug("save image desc");
				var gImageId = dojo.byId("galleryImageId").value;
				var gImageDesc = dojo.byId("imageDesc").value;
				var request = {
					url: '/simpdemo/gallery/add/',
					content: {
						id: gImageId,
						desc: gImageDesc,
					},
					load: function(data){
						retVal = dojo.fromJson(data);
						if (retVal.callback != null) {
							window.location = retVal.callback;
						}
					},
					error: function(data){
						console.debug("An error occurred: ", data);
					},
					timeout: 2000,
				};
				dojo.xhrPost(request);
			</script>
		</div>
		<input type="hidden" id="galleryImageId" value="{{galleryImage.pk}}" />
	</p>
	
	<p><a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/"><img alt="Creative Commons License" style="border-width:0" src="http://creativecommons.org/images/public/somerights20.png"/></a><br/>All <span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/StillImage" rel="dc:type">images</span> are licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License</a>.<br />
</div>
{% endblock content %}
